let WebSocketServer = require("ws");

let ws = new WebSocketServer.Server({
  port: 3005
});

let clients = [];

ws.on('connection', (client) => {

  clients.push(client);
  console.log(clients);
  client.on('message', (msg) => {
    console.log(JSON.parse(msg));
    // 转发给所有的客户端
    clients.forEach((clientItem) => clientItem.send(msg));
  });


});

